package com.lzh.persevere.controller;

import com.lzh.persevere.common.R;
import com.lzh.persevere.common.ResultUtil;
import com.lzh.persevere.model.qo.comment.CommentPageQO;
import com.lzh.persevere.model.qo.comment.ExpandSubCommentQO;
import com.lzh.persevere.model.ro.comment.SendCommentRO;
import com.lzh.persevere.model.vo.comment.CommentVO;
import com.lzh.persevere.service.CommentService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.Map;

/**
 * 评论controller
 *
 * @author luzhiheng
 * @since 2025-07-07
 */
@RestController
@RequestMapping("/comment")
public class CommentController {

    @Resource
    private CommentService commentService;

    @ApiOperation(value = "分页查询根评论")
    @PostMapping("/findCommentPageList")
    public R<Map<String, Object>> findCommentPageList(@Valid @RequestBody CommentPageQO qo) {
        return ResultUtil.success(commentService.pageList(qo));
    }

    @ApiOperation(value = "展开更多子级评论")
    @PostMapping("/expandMoreSubComment")
    public R<Map<String, Object>> expandMoreSubComment(@Valid @RequestBody ExpandSubCommentQO qo) {
        return ResultUtil.success(commentService.expandMoreSubComment(qo));
    }

    @ApiOperation(value = "发送评论")
    @PostMapping("/sendComment")
    public R<CommentVO> sendComment(@Valid @RequestBody SendCommentRO ro) {
        return ResultUtil.success(commentService.sendComment(ro));
    }
}
